<!DOCTYPE html>
<!--
首先感谢使用微笑开发程序，程序中如有不足，请多多指教与指导
使用源代码请勿删除声明文件，辛苦开源贡献代码不容易，请保留作者应该有的知晓权
同时感谢本系统中使用的框架和其他开源作者辛苦劳动成果，感谢！！
微笑交流QQ：512720913 邮箱地址：512720913@qq.com by.weixiao
-->
<html lang="zh-cn">
    <head>
        <meta charset="utf-8" /> 
        <title>注册新用户-Teamtalk非官方测试服务器</title>
<include file="Public:header" />
        <script language="javascript" type="text/javascript">
            $.ajaxSetup({
                cache: false //关闭AJAX相应的缓存
            });
            regErr = new Array();
            regErr[1] = '恭喜，该用户名可以使用';
            regErr[-1] = '用户名不合法';
            regErr[-2] = '包含不允许注册的词语';
            regErr[-3] = '用户名已存在';

            emailErr = new Array();
            emailErr[1] = '恭喜，该email可以使用';
            emailErr[-1] = '用户名不合法';
            emailErr[2] = '测试';
            emailErr[-5] = 'email不允许注册';
            emailErr[-6] = 'email已经被注册过了';
            var ddName;
            var ddNic;
            var ddPass;
            var ddPass2;
            var ddQq;
            var ddEmail;
            var ddYzm;
            function checkUsername(name) {
                if (getLength(name) < 3 || getLength(name) > 15)
                {
                    document.getElementById("ckuser").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>用户名长度必须为 5 - 20 位</font>';
                    ddName = 0;
                }
                else
                {
                    var re = RegExp("^[a-zA-Z0-9_]+$");
                    if (!re.test(name)) {
                        document.getElementById("ckuser").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>仅可使用数字字母和下划线</font>';
                        ddName = 0;
                    } else {
                        $.get("{:U('Home/index/ckuser')}", 'name=' + encodeURIComponent(name) + '&fresh=' + Math.random(), function (data) {
                           
                            data = parseInt(data);
                            if (data < 1) {
                                document.getElementById("ckuser").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>' + regErr[data] + '</font>';
                                ddName = 0;
                            } else {
                                document.getElementById("ckuser").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/dui.gif alt="正确" align=absmiddle /> <font color=#009900>' + regErr[data] + '</font>';
                                ddName = 1;
                            }
                        });
                    }
                }
            }
            
             function checknicname(name) {
                if (getLength(name) < 3 || getLength(name) > 15)
                {
                    document.getElementById("cknicname").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>用户昵称长度必须为 5 - 20 位</font>';
                    ddNic = 0;
                }
                
            }
            
            
            function getLength(str) {
                var len = str.length;
                var reLen = 0;
                for (var i = 0; i < len; i++) {
                    if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
                        // 全角    
                        reLen += 2;
                    } else {
                        reLen++;
                    }
                }
                return reLen;
            }

            function checkpass(password)
            {
                if (getLength(password) < 6 || getLength(password) > 20)
                {
                    document.getElementById("ckpass").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>密码长度必须为 6 - 20 位</font>';
                    ddPass = 0;
                }
                else
                {
                    var re = RegExp("^[a-zA-Z0-9_]+$");
                    if (!re.test(password)) {
                        document.getElementById("ckpass").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>仅可使用数字字母和下划线</font>';
                        ddPass = 0;
                    } else {
                        document.getElementById("ckpass").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写正确</font>';
                        ddPass = 1;
                    }
                }
            }

            function checkpass2()
            {
                if (getLength(document.getElementById("password_check").value) < 6 || getLength(document.getElementById("password_check").value) > 20)
                {
                    document.getElementById("ckpass2").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>密码长度必须为 6 - 20 位</font>';
                    ddPass2 = 0;
                }
                else if (document.getElementById("password").value != document.getElementById("password_check").value)
                {
                    document.getElementById("ckpass2").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>两次密码输入不一致！</font>';
                    ddPass2 = 0;
                }
                else
                {
                    document.getElementById("ckpass2").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码再次确认正确</font>';
                    ddPass2 = 1;
                }
            }
            function checkemail()
            {
                var str = document.getElementById("email").value;
              
        
                
                if (str.length != 0)
                {
                //   reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
                 //  var reg = RegExp("\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                      reg = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/;
                  
                    if (!reg.test(str))
                    
                    {
                        document.getElementById("ckemail").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>邮件格式填写错误</font>';
                        ddEmail = 0;
                    }
                    else
                    {
                        
                        $.get("{:U('Home/index/ckemail')}", 'email=' + encodeURIComponent(str) + '&fresh=' + Math.random(), function (data) {
                            data = parseInt(data);
                            if (data < 1) {
                                document.getElementById("ckemail").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>' + emailErr[data] + '</font>';
                                ddEmail = 0;
                            } else {
                                document.getElementById("ckemail").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/dui.gif alt="正确" align=absmiddle /> <font color=#009900>' + emailErr[data] + '</font>';
                                ddEmail = 1;
                            }
                        });
                    }
                }
                else
                {
                    document.getElementById("ckemail").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>请填写电子邮件</font>';
                    ddEmail = 0;
                }
            }
            
            function checkyzm()
            {
                var yzm = document.getElementById("yzm").value;
                if (getLength(yzm) != 4)
                {
                    document.getElementById("ckyzm").innerHTML = '&nbsp;<img src=__PUBLIC__/home/img/cuo.gif alt="错误" align=absmiddle /> &nbsp;<font color=#ff0000>验证码填写错误</font>';
                    ddYzm = 0;
                }
                else
                {
                    document.getElementById("ckyzm").innerHTML = '';
                    ddYzm = 1;

                }
            }
            function checkall()
            {
                checkUsername($('#account').val());
                checknicname($('#nicname').val());
                checkpass($('#password').val());
                checkpass2();
                checkemail();
                
                if (ddName == 0 || ddPass == 0 || ddPass2 == 0 || ddEmail == 0 || !document.getElementById("sm").checked)
                {
                    alert('请查看下文本框错误信息！');
                    return false;
                }
                else
                {
                    return true;
                }
            }
        </script>
    </head>
    <body>
      <include file="Public:menu" />
   

        <div class="width" id="reg_content" style="clear:both;text-align:center;margin:0px auto;position:relative; width:960px;">

          <div class="top">
                <div class="f_reight flow-steps">
                    <ol class="num3">
                        <li class="current"><strong class="first">1. 填写注册信息</strong></li>
                        <li class="last"><span>2. 注册成功</span></li>
                       
                    </ol>
                </div>
            </div>  
            <div class="reg_form" style="clear:both;text-align:left;margin:0px auto;position:relative; width:860px; border:1px solid #CCC; background:#F7F7F7;"><div style="height:20px;">&nbsp;</div>
                <form id="form" name="form" method="post" action="{:U('Index/checklogin')}" enctype="multipart/form-data" onsubmit="return checkall()">
                    <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">登录用户名：</span>        
                            <input name="account" type="text" onblur="checkUsername(document.getElementById('account').value);" id="account" tabindex="1" class="form-control" style="width:240px; background:#FFF; " />
                            <span id="ckuser" class=""></span>
                            <span class="form-tips">以字母开头,字母,数字,下划线的任意组合, 5-15字符限制。如:Bk71_888</span>
                        </label>
                    </div>
                     <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">电子邮箱：</span>
                            <input name="email" type="text" id="email" onblur="checkemail();" tabindex="5" class="form-control" style="width:240px; background:#FFF;" />
                            <span id="ckemail" class=""></span>
                            <span class="form-tips">有效的电子邮箱地址，用于找回密码等功能。</span>
                        </label>
                    </div>
                    
                      <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">用户昵称：</span>        
                            <input name="nicname" type="text" onblur="checknicname(document.getElementById('nicname').value);" id="nicname" tabindex="1" class="form-control" style="width:240px; background:#FFF; " />
                            <span id="cknicname" class=""></span>
                            <span class="form-tips">中文,字母,数字,下划线的任意组合, 5-15字符限制。如:微笑</span>
                        </label>
                    </div>
                    <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">登录密码：</span>
                            <input name="password" type="password" id="password" onblur="checkpass(document.getElementById('password').value);" tabindex="2" class="form-control" style="width:240px; background:#FFF;" />
                            <span id="ckpass" class="" style=""></span>
                            <span class="form-tips">以字母,数字,下划线的任意组合, 6-15字符限制。</span>
                        </label>
                    </div>
                    <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">重复密码：</span>        
                            <input name="password2" type="password" id="password_check" onblur="checkpass2();" tabindex="3" class="form-control" style="width:240px; background:#FFF;" />
                            <span id="ckpass2" class=""></span>
                            <span class="form-tips">请再次输入密码。</span>
                        </label>
                    </div>
                    
                       <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">用户图片：</span>
                           
                            <input name="imgurl" type="file" id="imgurl"  tabindex="5" class="form-control" style="width:240px; background:#FFF;" />
                            <span id="imgurl" class=""></span>
                            <span class="form-tips">请上传上传用户图片。</span>
                        </label>
                    </div>
                    
                      <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-name">
                            <span class="form-caption">手机号码：</span>
                            <input name="telno" type="text" id="email2"  tabindex="5" class="form-control" style="width:240px; background:#FFF;" />
                            <span id="telno" class=""></span>
                            <span class="form-tips">有效的手机号码，用于找回密码等功能。</span>
                        </label>
                    </div>
                
                   
                  
                    
<!--                    <div class="fffbox" style="margin-left:180px;">
                        <label for="reg-code">
                            <span class="form-caption">验证码：</span>
                            <input maxlength="5" name="yzm" type="text" id="yzm" onblur="checkyzm();" tabindex="7" class="form-control" style="width: 60px;" size="35" />

                            <img src="../comm/yzm.php" name="updateCode" id="getcode_num" border="0" align="absmiddle"/>
                            <script language="javascript" type="text/javascript">
                                $(function () {
                                    //数字验证 
                                    $("#getcode_num").click(function () {
                                        $(this).attr("src", '../comm/yzm.php?' + Math.random());
                                    });
                                });
                            </script>
                            <span id="ckyzm" class=""></span>
                            <span class="form-tips">输入图中的字符</span>
                        </label>
                    </div>-->
                   
                    <div class="fffbox" style="margin-left:180px;">
                        <span class="form-caption">&nbsp;</span>
                        <input value="提交注册" style="width: 149px;
                               height: 51px;
                               background:url(__PUBLIC__/home/img/btn_green.jpg) no-repeat;
                               color:#fff;
                               font-weight:bold;
                               font-size: 14px;
                               border:none;
                               cursor:pointer;" type="submit" name="Submit" tabindex="8" >
                    </div>
                </form>
            </div>

        </div>
  <div style="height:50px;">&nbsp;</div>

<include file="Public:footer" />
    </body>
</html>
